In Dr. DOBBS Sourcebook Nov/Dec 95 I came across a puzzling piece of code in an article describing a CGI library.
(Comments by me)
***
#include <signal.h>
#include <unistd.h>
#include "cgi-lib.h"
int main()
{ signal(SIGALRM, die); // Upon raising the SIGALRM signal it calls the DIE() function?
alarm(30); // Does this raise the SIGALRM signal after 30 seconds?
while(1) ; // just an infinite loop
}
***
Does this work? I haven't been able to test it out. Apparently my Borland compiler doesn't have UNISTD installed(???)
I'm working on a CGI processing class and I want to implement functionality to exit the program in case the user presses the 'Stop' button before the CGI-program has finished or the program goes into an infinte loop due to a flaw/bug in program design.
(This issue was of course pointed out by the author of the Dobb article. I hadn't thought of it myself)
Thanks a lot in advance,
-Laurence
PS. The CGI-programs run on a Unix server. (I use Windows at home)